--Universidade Federal de Campina Grande
--Centro de Enegenharia Elétrica e Informática
--Unidade Acadêmica de Sistemas e Computação
--Disciplina: Paradigmas de Linguagens de Programação
--Professor: Franklin Ramalho
--Equipe: Arthur Ribeiro
--        Felipe Vieira
--        Jeysibel Dantas
--        Paulo Victor
--Euphoric Checkers
--

include std/math.e

global constant TRUE = 1
global constant FALSE = 0
global constant WHITE_ORIGIN = 8
global constant BLACK_ORIGIN = 1
global atom tieCount = 0

function isBlack(integer i)
    return i=2 
end function

function isWhite(integer i)
    return i=1
end function

export function isBetween(atom number,sequence range)
    return number<=range[2] and number>=range[1]
end function


export function getDiagonalElementsBetween(sequence start, sequence finish)
    atom aux = 0
    
    sequence elements = {}
    
    atom lineStart = start[1]
    atom columnStart = start[2]
    atom lineStop = finish[1]
    atom columnStop = finish[2]
    
    -- If start line is superior to finish line
    if lineStart>lineStop then
        if columnStart>columnStop then
            for i=1 to abs(lineStart-lineStop) do           
            elements&=board[lineStart-i][columnStart-i]
            end for 
        end if
        
        if columnStart<columnStop then
            for i=1 to abs(lineStart-lineStop) do           
            elements&=board[lineStart-i][columnStart+i]
            end for 
        end if
    end if
    
    if lineStart<lineStop then
        if columnStart>columnStop then
            for i=1 to abs(lineStart-lineStop) do           
            elements&=board[lineStart+i][columnStart-i]
            end for 
        end if
        
        if  columnStart<columnStop then
            for i=1 to abs(lineStart-lineStop) do           
            elements&=board[lineStart+i][columnStart+i]
            end for 
        end if
    end if
    
    --?elements 
    return elements
    
end function
